﻿/*
TouchFramework connects touch tracking from a tracking engine to WPF controls 
allow scaling, rotation, movement and other multi-touch behaviours.

Copyright 2009 - Mindstorm Limited (reg. 05071596)

Author - Simon Lerpiniere

This file is part of TouchFramework.

TouchFramework is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

TouchFramework is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser Public License for more details.

You should have received a copy of the GNU Lesser Public License
along with TouchFramework.  If not, see <http://www.gnu.org/licenses/>.

If you have any questions regarding this library, or would like to purchase 
a commercial licence, please contact Mindstorm via www.mindstorm.com.
*/

using System.Drawing;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using CustomControls.InheritedFrameworkControls;
using CustomHelpers.Extensions;
using Color = System.Windows.Media.Color;

namespace TouchControls.ControlHandlers
{
    /// <summary>
    /// Custom logic for handling multi-touch button interation
    /// </summary>
    public class ViewboxHandler : ElementHandler
    {
        private byte _previousG;
        public override void Tap(PointF global, PointF relative)
        {
            var viewbox = Source as Viewbox;
            if (viewbox == null) return;
            //var paths = viewbox.FindChildren<Path>();
            //foreach (var path in paths)
            //{
            //    var brush = ((SolidColorBrush)path.Fill);
            //    if (brush == null) continue;
            //    var color = brush.Color;
            //    _previousG = color.G;
            //    path.Fill = new SolidColorBrush(Color.FromArgb(color.A, color.R, (byte)(255), color.B));
            //}
            var mapElement = viewbox.Tag as MapElement;
            mapElement.Activate();
            base.Tap(global, relative);
        }
    }
}
